<script type="text/javascript" src="${ctx}/resources/js/datatable-query.js"></script>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/common/taglibs.jsp"%>
<div class="row-fluid">
<div class="span12">
<div class="box gradient">
<div class="title">
<h4><span>Channel </span></h4>

<a href="#" class="minimize">Minimize</a></div>
<div class="content scrollable clearfix">
<table class="ajaxTable display table table-bordered">
	<thead>
		<tr>
			<th>Name</th>
			<th>Channel Template</th>
			<th>Visit Path</th>
			<th>Action</th>
		</tr>
	</thead>
</table>
</div>
</div>
</div>
</div>
<div>
<script type="text/javascript">

var render = false;
var oTime = "";
var oTable;
$(document).ready(function () {
	oTable = $('.ajaxTable').dataTable({
		"bLengthChange": true,
		"sAjaxSource": '${ctx}/channel/',
		"fnInitComplete": function (oSettings, json) { }
	});
	var name = $("<input>").attr({
		type: "text",
		field: "name",
		op: "cn",
		placeholder: "Channel Name",
		class: "filterdata"
	});
	var searchLabel = $("<label>").html("Search:").css("display", "inline");
	var filterDiv = $("<div>").addClass("dataTables_filter").append(searchLabel).append(name);
	$('.dataTables_wrapper').prepend(filterDiv);

	$(".filterdata").keyup(function () {
		updateGrid();
	});
 	
});
function updateGrid() {
	window.clearTimeout(oTime);
	oTime = setTimeout(function () { oTable.fnDraw(); }, 500);
}

var columnHeader = ['name', 'selfTemplate.name', 'path'];
var QueryData = function (aoData) {
	return johnny.initQueryData(aoData, columnHeader);
}

var DataTableForm = function (json, echo) {
	var dataArray = new Array();
	for (var i = 0; i < json.result.length; i++) {
		var link = "${ctx}/channel/"+json.result[i].id+"/edit/";
		var view = "${ctx}/"+json.result[i].path;
		var inline = "${ctx}/LG-en/24k-editor/"+json.result[i].path+"/";
		var subArray = new Array();
		subArray.push(json.result[i].name);
		subArray.push(json.result[i].selfTemplate.name);
		subArray.push(json.result[i].path);
		if (json.result[i].selfTemplate.inlineEdit){
			subArray.push(johnny.getInlineAndEdit(link,inline,view));
		}else{
			subArray.push(johnny.getInlineAndEdit(link,null,view));
		}
		console.dir()
		dataArray.push(subArray);
	}
	return {
		sEcho: echo,
		iTotalRecords: json.totalCount,
		iTotalDisplayRecords: json.totalCount,
		aaData: dataArray
	};
}
</script>






<a href="${ctx}/channel/create/" class="btn btn-info"> <span class="icon12 icomoon-icon-plus white"></span> New</a></div>